BinarySearch[numlist_, elem_] :=
	Module[{n0 = 1, n1 = Length[numlist], m},
		While[n0 <= n1,
		  	m = Floor[(n0 + n1)/2];
		  	If[ numlist[[m]] == elem, Return[m] ]; (* found *)
		  	If[ numlist[[m]] < elem, n0 = m+1, n1 = m-1 ]];
	 	0]

{BinarySearch[{1,3,5,7,9,11},8],
BinarySearch[{1,3,5,7,9,11},7]}

BinarySearch1[numlist_, elem_] :=
	Module[{n0 = 1, n1 = Length[numlist], m},
		While[n0 <= n1,
		   	m = Floor[(n0 + n1)/2];
		   	If[ numlist[[m]] == elem, Break[] ]; (* found *)
		   	If[ numlist[[m]] < elem, n0 = m+1, n1 = m-1 ]];
		If[ n0 > n1, 0, m ]	]

{BinarySearch1[{1,3,5,7,9,11},8],
BinarySearch1[{1,3,5,7,9,11},7]}

BinarySearch2[numlist_, elem_] :=
	Module[{n0 = 1, n1 = Length[numlist], m, found=False},
		While[n0 <= n1 && !found,
			   m = Floor[(n0 + n1)/2];
			   If[ numlist[[m]] == elem, found=True]; (* found *)
			   If[ numlist[[m]] < elem, n0 = m+1, n1 = m-1 ]];
   If[found, m,0 ]	]

{BinarySearch2[{1,3,5,7,9,11},8],
BinarySearch2[{1,3,5,7,9,11},7]}

{1,3,5,7,9,11}[[BinarySearch2[{1,3,5,7,9,11},9]]]